package com.example.demoapp.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configurable说明这是一个配置类
@Configuration
public class WebConfig implements WebMvcConfigurer {
    // 关键：通过 @Autowired 获取 Spring 管理的拦截器实例
    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")//拦截所有的接口
                .excludePathPatterns("/login")//放行
                .excludePathPatterns("/register")//放行
                .excludePathPatterns("/employee/download/**");
    }
}

